package com.soilflow.web.controller.dahu.web;

import com.soilflow.common.annotation.Log;
import com.soilflow.common.core.controller.BaseController;
import com.soilflow.common.core.domain.AjaxResult;
import com.soilflow.common.core.page.TableDataInfo;
import com.soilflow.common.domain.DahuBusiness;
import com.soilflow.common.domain.DahuConvenient;
import com.soilflow.common.domain.dto.DahuConvenientDto;
import com.soilflow.info.service.IDahuConvenientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.soilflow.common.utils.PageUtils.startPage;

@RestController
@RequestMapping("/reception/convenient")
public class ConvenientController extends BaseController{
    @Autowired
    private IDahuConvenientService convenientService;
    /**
     * 查询便民信息
     */
    @GetMapping("/list")
    public TableDataInfo list(DahuConvenientDto dto)
    {
        startPage();
        List<DahuConvenientDto> list = convenientService.selectConvenientList(dto);
        return getDataTable(list);
    }
    @PutMapping("/updateViewCount/{id}")
    public AjaxResult updateViewCount(@PathVariable("id") Long id){
        return AjaxResult.success(convenientService.updateViewCount(id));
    }
    /**
     * 获取文章详情
     */
    @GetMapping("/{id}")
    public AjaxResult getConvenient(@PathVariable("id") Long id){
        return AjaxResult.success(convenientService.getConvenient(id));
    }
    @PutMapping
    public AjaxResult updateDahuConvenient(@RequestBody DahuConvenient convenient){
        return AjaxResult.success(convenientService.updateById(convenient));
    }
    @PostMapping
    public AjaxResult add(@RequestBody DahuConvenient convenient){
        return AjaxResult.success(convenientService.add(convenient));
    }
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable("id") Long id){
        return AjaxResult.success(convenientService.removeById(id));
    }
}
